package com.sitanyun.merchant.guide.frament.model.impl;

import com.google.gson.Gson;
import com.sitanyun.merchant.guide.bean.QueryBean;
import com.sitanyun.merchant.guide.callback.StringCallbacks;
import com.sitanyun.merchant.guide.frament.model.inter.IShtopFModel;
import com.sitanyun.merchant.guide.presenter.callback.CallBack;
import com.sitanyun.merchant.guide.url.Urls;
import com.sitanyun.merchant.guide.weiht.SharedPreferenceUtil;
import com.zhy.http.okhttp.OkHttpUtils;

import okhttp3.Call;

/**
 * 排名
 */
public class ShtopFModelImpl implements IShtopFModel {
    @Override
    public <T> void setquery(String queryMonth, String queryType, CallBack callBack) {

        OkHttpUtils.get()
                .addHeader("Authorization","Bearer "+ SharedPreferenceUtil.getStringData("token"))
                .addHeader("Content-Type", "application/json")
                .url(Urls.querycount)
                .addParams("queryMonth",queryMonth)
                .addParams("queryType",queryType)
                .build().execute(new StringCallbacks() {
            @Override
            public void onError(Call call, Exception e, int id) {
            }
            @Override
            public void onResponse(String response, int id) {
                QueryBean baseEntity= new Gson().fromJson(response, QueryBean.class);
                callBack.onSuccess(baseEntity);
            }
        });
    }
}
